package com.quanyan.runningriding.web.running.Admin;


import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.runningriding.entity.vo.run.resp.MusicLovePersonVo;
import com.quanyan.runningriding.entity.vo.run.resp.MusicPlayPersonVo;
import com.quanyan.runningriding.service.RunMusicStatisticsService;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by liubin on 2016/11/19.
 */
@RestController
@RequestMapping(value = "/admin/api/run")
public class MusicStatisticsAdminController {
    @Autowired
    private RunMusicStatisticsService runMusicStatisticsService;
    private Logger logger = LoggerFactory.getLogger(MusicStatisticsAdminController.class);


    @RequestMapping(value = "/musicCollectionLovePersonList", method = RequestMethod.POST)
    public APIResponse<PageObj<List<MusicLovePersonVo>>> musicCollectionLovePersonList(@RequestBody Map<String, Object> paramMap) {
        Integer pageNum = MapUtils.getInteger(paramMap, "pageNum");
        Integer pageSize = MapUtils.getInteger(paramMap, "pageSize");
        String markLoveMinTime = MapUtils.getString(paramMap, "markLoveMinTime");
        String markLoveMaxTime = MapUtils.getString(paramMap, "markLoveMaxTime");
        Byte isCache = MapUtils.getByte(paramMap, "isCache");
        PageObj<List<MusicLovePersonVo>> result = runMusicStatisticsService.musicLovePersonList(markLoveMinTime, markLoveMaxTime, isCache, pageNum, pageSize);
        return APIResponse.returnSuccess(result);
    }
    @RequestMapping(value = "/musicCollectionPlayPersonList", method = RequestMethod.POST)
    public APIResponse<PageObj<List<MusicPlayPersonVo>>> musicCollectionPlayPersonList(@RequestBody Map<String, Object> paramMap) {
        Integer pageNum = MapUtils.getInteger(paramMap, "pageNum");
        Integer pageSize = MapUtils.getInteger(paramMap, "pageSize");
        String playMinTime = MapUtils.getString(paramMap, "playMinTime");
        String playMaxTime = MapUtils.getString(paramMap, "playMaxTime");
        PageObj<List<MusicPlayPersonVo>> result = runMusicStatisticsService.musicCollectionPlayPersonList(playMinTime, playMaxTime, pageNum, pageSize);
        return APIResponse.returnSuccess(result);
    }

}